package com.lhd.web.admin;

import com.lhd.po.User;
import com.lhd.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * Created by liuhandong on 2022/4/20.
 */
@RestController
public class LoginController {


    @Autowired
    private UserService userService;

    @PostMapping("/admin/login")
    public Integer login(@RequestBody User u, HttpSession session){
        User user = userService.checkUser(u.getUsername(),u.getPassword());
        if (user != null){
            session.setAttribute("user",user);
            return 1;
        }else {
            return 0;
        }
    }
}
